/**
 * Created by leiweibo on 7/25/15.
 */
var app = angular.module('labfeeservice', []);
app.factory('LabFeeService', function($http, BaseService) {

  function getPage(province, hospital, pageNo, pageSize, params, success) {

    var filterCondition = params.search.predicateObject;
    var queryStr = '';
    if (filterCondition) { //TODO
      if (filterCondition.username) {
        queryStr += ('&username=' + filterCondition.username);
      }

      if (filterCondition.realname) {
        queryStr += ('&realname=' + filterCondition.realname);
      }
    }

    if (province) {
      queryStr += ('&province=' + province);
    }
    if (hospital) {
      queryStr += ('&hospital=' + hospital);
    }
    $http.get(BaseService.baseUrl + "/lab_fee/list?pageNo=" + pageNo + "&pageSize=" + pageSize + queryStr)
      .success(success);
  }

  return {
    create: function(data, success, error) {
      $http.post(BaseService.baseUrl + '/lab_fee/create', data).success(success).error(error);
    },

    list: getPage

  }
});
